<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <style>
        .inp {
            width: 300px;
        }
    </style>
</head>

<body>
    <div id="content"></div>
    <template id="tem1">
        <div>
            <h2>添加页面</h2>
            <el-form ref="form" label-width="80px">
                <el-form-item label="姓名：">
                    <el-input class="inp" placeholder="姓名" v-model="users.username"></el-input>
                </el-form-item>
                <el-form-item label="年龄：">
                    <el-input class="inp" placeholder="年龄" v-model="users.age"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" :plain="true" @click="add()">添加</el-button>
                    <el-button @click="ret()">返回</el-button>
                </el-form-item>
            </el-form>
        </div>
    </template>
    <script src="./js/vue.min.js"></script>
    <script src="./js/jquery.min.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script>
        var vm = new Vue({
            el: '#content',
            template: '#tem1',
            data: function () {
                return {
                    users: {
                        username: '',
                        age: ''
                    }
                }
            },
            methods: {
                add: function () {
                    var _this = this
                    $.post('/users/add', this.users).done(function () {
                            location.href = './elindex.html'
                    })
                },
                ret: function () {
                    location.href = './elindex.html'
                },
            }
        })
    </script>
</body>

</html>